using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace AutoFormatter
{
    public class FontPicker:LinkLabel,INotifyPropertyChanged
    {
        public FontPicker()
        {
            f = base.Font;
        }

        Font f;
        [Bindable(true)]
        [SettingsBindable(true)]
        public Font Value
        {
            get { return f; }
            set
            {
                f = value;
                if (PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("Value"));
            }
        }

        public override string Text
        {
            get
            {
                return 
                    f==null
                        ? "not set"
                        : string.Format("[{0}] {1}" ,Math.Round(Value.SizeInPoints), Value.Name);
            }
        }

        protected override void OnClick(EventArgs e)
        {
            FontDialog fd = new FontDialog();
            fd.Font = Value;
            if (fd.ShowDialog(this) == DialogResult.OK)
            {
                Value = fd.Font;
            }
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
